package com.hyh.shiyanshiguanli.config;

/**
 * @author hyh
 * @version 1.0
 */



import com.hyh.shiyanshiguanli.properties.AliOssProperties;
import com.hyh.shiyanshiguanli.utils.AliOssUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置类用于创建AliOssUtils对象,并将创建的类返回给IOC容器管理
 */
@Slf4j
@Configuration
public class OssConfiguration {


    @Bean
    @ConditionalOnMissingBean
    public AliOssUtil aliOssUtil(AliOssProperties aliOssProperties) {
        log.info("开始创建阿里云上传文件对象{}",aliOssProperties);
        return new AliOssUtil(aliOssProperties.getEndpoint()
                ,aliOssProperties.getAccessKeyId()
                ,aliOssProperties.getAccessKeySecret()
                ,aliOssProperties.getBucketName());
    }
}
